package com.huilian.iotbox.admin.wap.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.huilian.iotbox.admin.wap.dao.RoleDao;
import com.huilian.iotbox.admin.wap.service.RoleService;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.dto.RoleDto;
import com.huilian.iotbox.data.dto.RolePermissionTempDto;
import com.huilian.iotbox.data.vo.MemberVo;
import com.huilian.iotbox.data.vo.RoleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.xml.ws.soap.Addressing;
import java.util.List;

/**
 * @author LinYinDong
 * @date 2024/10/11 上午11:15
 */
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleDao roleDao;
    @Override
    public ServerResponse findRoleList(RoleDto roleDto) {
        PageHelper.startPage(roleDto.getPageNum(), roleDto.getPageSize(), true);
        PageHelper.orderBy("r.updateTime desc");
        List<RoleVo> roleList = roleDao.findRoleList(roleDto);
        PageInfo pageResult = new PageInfo(roleList);
        return ServerResponse.createBySuccess(pageResult);
    }

    @Override
    public RoleVo getOneRoleByIdAndUserId(RolePermissionTempDto rolePermissionTempDto) {
        return roleDao.getOneRoleByIdAndUserId(rolePermissionTempDto);
    }

    @Override
    public ServerResponse findRoleByUserIdList(RoleDto roleDto) {
        return ServerResponse.createBySuccess(roleDao.findRoleByUserIdList(roleDto));
    }
}
